package com.sghd.candy.module.rank.facade;

import com.sghd.candy.module.player.manager.Player;
import com.sghd.candy.module.player.service.PlayerService;
import com.sghd.candy.module.rank.service.RankService;
import com.sghd.pojo.candy.rank.RankList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Allen
 * @date 2018/12/28
 */
@Component
public class RankFacadeImpl implements RankFacade {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private RankService rankService;

    @Autowired
    private PlayerService playerService;

    @Override
    public RankList getRank(long playerId) {
        try {
            Player player = playerService.load(playerId);
            return rankService.getRank(player);
        } catch (Exception e) {
            logger.error("玩家[{}]获取排行榜数据发生未知错误！", playerId, e);
        }
        return new RankList();
    }
}
